#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n, m, sx, sy;
  cin >> m >> n >> sx >> sy;
  auto matrix = vector(n, vector(m, pair<int, int>()));
  // vector<vector<pair<int, int>>> matrix(n, vector<pair<int, int>>(m));
  for (auto &line : matrix) {
    for (auto &[x, y]: line) cin >> x >> y;
  }
  do {
    cout << sx << ' ' << sy << endl;
    tie(sx, sy) = matrix[sx - 1][sy - 1];
    // auto temp = matrix[sx][sy];
    // sx = temp.first;
    // sy = temp.second;
  } while (sx != 0 && sy != 0);
}